﻿#region Using Directives

using System;
using System.Collections.Generic;

using Microsoft.SharePoint;

#endregion Using Directives

namespace SharePointStu.ItemAuditing.Audit
{
    class ListAuditEntries : AbstractAuditEntries
    {
        #region Constructor

        public ListAuditEntries(Guid webId, Guid listId) : base(webId, listId)
        {
        }

        #endregion Constructor

        #region Constants

        const string COLUMN_TYPE = "Type";

        #endregion Constants

        #region Overridden Methods

        public override List<AuditColumn> DefineColumns()
        {
            List<AuditColumn> columns = base.DefineColumns();
            InsertColumn(ref columns, COLUMN_USERNAME, COLUMN_TYPE, typeof(string));

            return columns;
        }

        public override string GetFilterColumns()
        {
            string filter = base.GetFilterColumns();
            return InsertFilter(filter, COLUMN_USERNAME, COLUMN_TYPE);
        }

        public override Dictionary<string, string> AddRow(SPAuditEntry entry)
        {
            Dictionary<string, string> row = null;
            row = base.AddRow(entry);

            if (row != null)
            {
                row.Add(COLUMN_TYPE, entry.ItemType.ToString());
            }
            return row;
        }

        #endregion Overridden Methods
    }
}
